package br.com.ps.bombertournament.game.action;

import br.com.ps.bombertournament.game.BaseAction;
import br.com.ps.bombertournament.game.BaseGameObject;
import br.com.ps.bombertournament.game.WrapperMap;

/**
 * Start a animation on the game object
 * 
 * @author Rennan Stefan Boni - rennanboni@gmail.com
 */
public class PlayAnimationAction extends BaseAction {

	private static final String ANIMATION_PROPERTY = "animation";
	
	private String animation;
	
	@Override
	public void create() {
		// Search the animation name to be played 
		WrapperMap parameters = super.getParameters();
		if (parameters.containsKey(ANIMATION_PROPERTY)) {
			animation = parameters.getString(ANIMATION_PROPERTY);
		}
	}

	@Override
	public void execute(BaseGameObject owner) {
		// Start the animation
		if (animation != null) {
			owner.play(animation);
		}
		
		super.setExecuted(true);
	}

	@Override
	public void undo(BaseGameObject owner) {
		// Do nothing
	}
}
